package lib;

/**
 * ...
 * @author test
 */
class Fiber {
	public static var path = untyped __js__('__dirname');
	public static var file = untyped __js__('__filename');
	public static var setTimeout:Dynamic->Int->?Array<Dynamic>->Int = untyped __js__('setTimeout');
	public static var clearTimeout:Int->Void = untyped __js__('clearTimeout');
	public static var setInterval:Dynamic->Int->?Array<Dynamic>->Int = untyped __js__('setInterval');
	public static var clearInterval:Int->Void = untyped __js__('clearInterval');
	public static var global:Dynamic = untyped __js__('global');
	public static var stringify:Dynamic->?Dynamic->?Dynamic->String = untyped __js__('JSON.stringify');
	public static var parse:String->Dynamic = untyped __js__('JSON.parse');

	public static function hasTrue(data:Dynamic):Bool {
		return untyped __js__('!!{0}', data);
	}

	/**
	 * 删除对象成员
	 * @param data 对象成员
	 */
	public static function delete(data:Dynamic, ele:Dynamic) {
		return untyped __js__('delete {0}[{1}]', data, ele);
	}

	/**
	 * 数组连续操作
	 * @param data 对象成员
	 */
	public static function arrconat(data:Dynamic, data2:Dynamic) {
		return untyped __js__('{...{0},...{1}}', data, data2);
	}
}



@:native("JSON")
extern class Json {
	public static function stringify(data:Dynamic):Dynamic;
	public static function parse(data:Dynamic):Dynamic;
}

@:native("console")
extern class Console {
	public static function log(data:haxe.extern.Rest<Dynamic>):Void;
	public static function info(data:haxe.extern.Rest<Dynamic>):Void;
	public static function warn(data:haxe.extern.Rest<Dynamic>):Void;
	public static function error(data:haxe.extern.Rest<Dynamic>):Void;
	public static function exception(data:haxe.extern.Rest<Dynamic>):Void;
	public static function debug(data:haxe.extern.Rest<Dynamic>):Void;
	public static function table(data:haxe.extern.Rest<Dynamic>):Void;
	public static function trace():Void;
	public static function dir(data:haxe.extern.Rest<Dynamic>):Void;
	public static function dirxml(data:haxe.extern.Rest<Dynamic>):Void;
	public static function group(data:haxe.extern.Rest<Dynamic>):Void;
	public static function groupCollapsed(data:haxe.extern.Rest<Dynamic>):Void;
	public static function groupEnd(data:haxe.extern.Rest<Dynamic>):Void;
	public static function time(?time:Dynamic):Void;
	public static function timeEnd(?time:Dynamic):Void;
	public static function timeStamp(?data:Dynamic):Void;
	public static function profile(data:haxe.extern.Rest<Dynamic>):Void;
	public static function profileEnd(data:haxe.extern.Rest<Dynamic>):Void;
	public static function assert(condition:Bool, data:haxe.extern.Rest<Dynamic>):Void;
	public static function count(data:haxe.extern.Rest<Dynamic>):Void;
	public static function clear():Void;
	public static function markTimeline():Void;
	public static function timeline():Void;
	public static function timelineEnd():Void;
}
